package com.jml.咕泡.手写mybatisV1.mapper;

import com.jml.咕泡.手写mybatisV1.session.GpSqlSession;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MapperProxy<T> implements InvocationHandler {

	private final  GpSqlSession sqlSession;
	private final Class<T> mapperInterface;

	public  MapperProxy(GpSqlSession gpSqlSession, Class<T> clazz) {
		this.sqlSession =gpSqlSession;
		this.mapperInterface=clazz;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		if(method.getDeclaringClass().getName().equals(sqlSession.getConfiguration())){
			String sql = "";
			return sqlSession.selectOne(sql,String.valueOf(args[0]));
		}
		return method.invoke(proxy, args);
	}
}
